package com.common.retrofit.methods;

import com.common.carbean.CountInfoBean;
import com.common.cons.Constans;
import com.common.retrofit.base.BaseMethods;
import com.common.retrofit.service.HaiNingService;
import com.common.utils.SortUtils;

import rx.Observable;
import rx.Subscriber;

public class LoginMethods extends BaseMethods {

    private static LoginMethods m_ins = null;

    public static LoginMethods getInstance() {
        if (m_ins == null) {
            synchronized (LoginMethods.class) {
                if (m_ins == null) {
                    m_ins = new LoginMethods();
                }
            }
        }
        return m_ins;
    }

    @Override
    protected String getHttpUrl() {
        return "Api/User/";
    }

    private HaiNingService initService() {
        return getRetrofit().create(HaiNingService.class);
    }


    public void     login(Subscriber<CountInfoBean> subscriber,
                      String mobile,
                      String checkcode  ,String jpushid ) {
        String time  = System.currentTimeMillis()+"" ;
        Observable observable = initService().countLogin(time,
                SortUtils.getMyHash("mobile"+mobile,"checkcode"+checkcode,"time"+time,"jpushid"+jpushid), Constans.ANDROID_APP_ID,"3",mobile,checkcode,jpushid
        );
        toSubscribe(observable, subscriber);
    }
}
